package code.db;

import org.apache.commons.lang.StringUtils;

import code.db.executor.DefaultDBExecutor;
import code.db.executor.MySQLExecutor;
import code.db.executor.OracleExecutor;

public class DBExecutorFactory {
	
	private DBExecutor executor = null;
	
	private String dbType = "";

	public String getDbType() {
		return dbType;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}
	
	public DBExecutor getExecutor(){
		if(executor == null){
			if(StringUtils.equalsIgnoreCase(dbType, "oracle")){
				executor = new OracleExecutor();
			}
			else if(StringUtils.equalsIgnoreCase(dbType, "mysql")){
				executor = new MySQLExecutor(); 
			}
			else{
				executor = new DefaultDBExecutor(); 
			}
		}
		return executor;		
	}
}
